<?php
/**
 * Author: Long Doan
 * Date: 3/24/11 10:07 PM
 */
require_once("../../../wp-config.php");
require_once("functions.php");

if (!wp_verify_nonce($_GET['nonce'], 'wv_widget_ajax')) die('Busted');

$post_id = intval($_GET['post_id']);
query_posts(array('p' => $post_id, 'post_type' => array('music', 'video')));

add_filter('comments_template', 'wv_comments_template');
function wv_comments_template($path)
{
	$path = WV_ABSPATH . '/lib/views/comments.php';
	return $path;
}

?>

<div id="wv_lightbox">
	<?php global $more; if ( have_posts() ) while ( have_posts() ) : the_post(); $more = 0; ?>
		<div class="wv-entry-content">
			<?php the_content(''); ?>
		</div>
		<div class="wv-entry-wrapper">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td class="detailsCell">
						<div class="detailContainer">
							<div class="entry-title">
								<strong><?php the_title() ?></strong>
							</div>
							<span class="subline">Video of the day: 26.03.2011 </span>
							<hr class="mvm">
							<div class="entry-action">
								<?php the_rw_iframe() ?>
								<?php the_fb_button() ?>
							</div>
						</div>
					</td>
					
					<td class="commentCell">
						<div class="commentsContainer">
							
							<div class="descriptions">
								<?php if (strpos($post->post_content, '-->')) : ?>
								<?php $aftermore = 3 + strpos($post->post_content, '-->');
								echo substr($post->post_content,$aftermore);
								?>
								<?php endif; ?>
							</div>
							
							<?php comments_template( '', true ); ?>
							
							<div style="font-weight: bold;" id="wv_ajax_result"></div>

							</div><!-- #comments -->
						</div>
					</td>
				</tr>
			</table>
		</div>
	<?php endwhile; // end of the loop. ?>
</div>

<?php 
	global $AudioPlayer, $rwp;  

	if (strlen($AudioPlayer->playerID) > 0) {
		$playerElementID = "audioplayer_" . $AudioPlayer->playerID;
		$embedCode = str_replace($playerElementID, 'facebox_'.$playerElementID, $AudioPlayer->footerCode);
		
		if (strlen($embedCode) > 0) : 
?>			
			<script type="text/javascript">
			jQuery(document).bind('reveal.facebox', function() {
				<?php echo $embedCode; ?>
			})
			
			</script>
<?php
		endif;
	}
	
	
?>